package cn.itcast.service.cargo.impl;

import cn.itcast.dao.cargo.FinanceDao;
import cn.itcast.domain.cargo.Finance;
import cn.itcast.domain.cargo.FinanceExample;
import cn.itcast.service.cargo.FinanceService;
import com.alibaba.dubbo.config.annotation.Service;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;
import java.util.UUID;

@Service(timeout = 200000) // 设置超时时间为200秒
public class FinanceServiceImpl implements FinanceService {

    @Autowired
    private FinanceDao financeDao;

    @Override
    public int insert(Finance finance) {
        //1. 设置uuid
        finance.setFinanceId(UUID.randomUUID().toString());
        return financeDao.insert(finance);
    }

    @Override
    public int insertSelective(Finance record) {
        return financeDao.insertSelective(record);
    }

    @Override
    public List<Finance> selectByExample(FinanceExample financeExample) {
        return financeDao.selectByExample(financeExample);
    }

    @Override
    public PageInfo<Finance> findByPage(FinanceExample financeExample, int pageNum, int pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        List<Finance> list = financeDao.selectByExample(financeExample);
        return new PageInfo<>(list);
    }

    @Override
    public Finance findById(String id) {
        return financeDao.findById(id);
    }
}
